<template>
	<view >
		<view v-if="!orderCurrentList.length" >
			<emptyOrder></emptyOrder>
		</view>
		<view style="margin-top: 100rpx;margin-bottom: 100rpx;">
			<view v-if="orderCurrentList.length" v-for="(value,key,index) in total_list" class="list">
				<view  style="padding: 20rpx;border-radius: 30rpx;width: 720rpx;background-color: white;display: flex;flex-direction: column;align-items: center;">
					<span >订单号：{{key.slice(1,key.length)}}</span>
					<view v-for="(item,index) in value" style="width: 600rpx;">
						<view style="display: flex;margin-top: 30rpx;">
							<image :src="item.image_name" style="width: 150rpx;height: 220rpx;"></image>
							<view style="height: 220rpx;width: 500rpx;display: flex;justify-content: space-between;">
								<view style="display: flex;flex-direction: column;height: 220rpx;justify-content: space-around;">
									<span style="color: black;font-size: 35rpx;font-weight: bold;">{{item.name}}</span>
									<span style="font-size: 30rpx;color: darkgray">{{item.detail}}</span>
									<span style="font-size: 30rpx;color: green;">×{{item.num}}</span>
								</view>
								<view style="height: 100%;display: flex;flex-direction: column;justify-content: space-between;">
									<span style="color: green;font-size: 35rpx;font-weight: bold;margin-top: 20rpx;">￥{{item.price}}</span>
									<span style="color: green;font-size: 35rpx;font-weight: bold;margin-bottom: 10%;">{{item.status}}</span>
								</view>
								
							</view>
							
						</view>
						
					</view>
				</view>
				
					
			</view>
		</view>
	</view>
</template>

<script>
	import emptyOrder from "../emptyOrder/emptyOrder.vue"
	export default {
		data() {
			return {
				status:true,
				orderCurrentList:[],
				total_list:{}
			}
		},
		methods: {
			
		},
		components:{
			emptyOrder
		},
		onShow() {
			
		},
		created() {
			
			var t=this
			uni.request({
				url:"http://localhost:3000/getCurrentOrders",
				success(data) {
					//console.log(data.data)
					
					t.orderCurrentList=data.data
					let single_list=[]
					
					for(let i=0;i<t.orderCurrentList.length;i++){
						
						if(single_list.indexOf(t.orderCurrentList[i].order_id)==-1){
							single_list.push(t.orderCurrentList[i].order_id)
						}
					}
					single_list=single_list.reverse()
					for(let i=0;i<single_list.length;i++){
						let items=[]
						for(let ii=0;ii<t.orderCurrentList.length;ii++){
							if(t.orderCurrentList[ii].order_id==single_list[i]){
								items.push(t.orderCurrentList[ii])
							}
						}
						console.log("",items);
						t.$set(t.total_list,"l"+single_list[i],items)
						
					}
					
					console.log("333333333",t.total_list);
				}
			})
		},
	}
</script>

<style>
.list{
		
		display: flex;
		width: 720rpx;
		align-items: center;
		flex-direction: column;
		
		
		padding: 30rpx;
	}
</style>
